#include <bits/stdc++.h>
using namespace std;
int n, m, L, V, T, p[114514];
int inf = 1000005;
struct Car{
    int d, v, a;
    vector <int> can;
} c[11451];
int p_find(double x){
    int l = 1, r = m + 5, mid;
    while (l < r){
        mid = (l + r) >> 1;
        if (p[mid] > x) r = mid;
        else l = mid + 1;
    }
    return l;
}
double mmm(int V, int cv, int ca, int cd){
    double dV = V, dcv = cv, dca = ca, dcd = cd;
    return (dV * dV - dcv * dcv) / (2 * dca) + dcd;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    for (int t = 0; t < T; t ++){
        int ans1 = 0, ans2 = m;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i ++) cin >> c[i].d >> c[i].v >> c[i].a;
        for (int i = 1; i <= m; i ++) cin >> p[i];
        sort(p + 1, p + m + 1);
        p[m + 1] = inf;
        vector <int> cs;
        for (int i = 1; i <= n; i ++){
            int cv = c[i].v, ca = c[i].a, cd = c[i].d;
            if (ca == 0){
                if (cv > V){
                    ans1 ++;
                    cs.push_back(i);
                    for (int j = p_find(cd); j <= m; j ++) c[i].can.push_back(j);
                }
                else continue;
            }
            else if (ca > 0){
                double md = mmm(V, cv, ca, cd);
                if (md > L) continue;
                int add;
                for (int j = p_find(md); j <= m; j ++){
                    c[i].can.push_back(j);
                    add = 1;
                }
                ans1 += add;
                if (add) cs.push_back(i);
            }
            else{
                double md = mmm(V, cv, ca, cd);
                if (md < cd) continue;
                int add = 0;
                for (int j = p_find(cd); j < p_find(md); j ++){
                    c[i].can.push_back(j);
                    add = 1;
                }
                ans1 += add;
                if (add) cs.push_back(i);
            }
        }
        cout << ans1 << " ";

        vector <int> ps[1145];
        for (int i = 0; i < (int)cs.size(); i ++){
            for (int j = 0; j < (int)c[cs[i]].can.size(); j ++){
                ps[j].push_back(cs[i]);
            }
        }
        ans2 = m;
        for (int i = 1; i <= m; i ++){
            if (ps[i].empty()){
                ans2 --;
                continue;
            }
            int radd = 1;
            for (int j = 0; j < (int)ps[i].size(); j ++){
                for (int i2 = i + 1; i2 <= m; i2 ++){
                    if (ps[i2].empty()) continue;
                    for (int j2 = 0; j2 < (int)ps[i2].size(); j2 ++){
                        if (ps[i][j] != ps[i2][j2]) radd = 0;
                    }
                }
            }
            ans2 -= radd;
        }
        cout << m - ans2 - 1 << endl;
    }
    return 0;
}
